N_Tree<Node,Type,nchild>\f1 A parameterized N-ary tree class
.SH SYNOPSIS
#include <cool/N_Tree.h>
.SH DESCRIPTION
The \f3N_Tree<Node,Type,nchild>\f1 class implements n-ary trees, providing the
organizational structure for a tree (collection) of nodes, but knowing nothing
about the specific type of node used. \f3N_Tree<Node,Type,nchild>\f1 is parameterized
over a node type, a data type, and a subtree count, where the node specified
must have a data member of the same
Type
as the tree class and the subtree
count indicates the number of possible subtree pointers (children) from any
given node. Two node classes are provided, but others could also be written.
The \f3N_Node<Type> \f1class implements static-sized nodes for some distinct number of subtrees, and the \f3D_Node<Type>\f1 class implements dynamic-sized nodes derived from the \f3Vector<Type>\f1 class.
.PP
Since the organization of a tree is important (as with an expression tree),
the user must supervise the construction of the tree by directing specific node
and subtree assignments and layout. No attempt is made by the
\f3N_Tree<Node,Type,nchild>\f1 class to balance or prune the tree.
.PP
The \f3N_Tree<Node,Type,nchild>\f1 class implements the notion of a current position.
This is useful for iterating through the nodes of a tree. The current position
is maintained in a data member of type
N_Tree_state
and is set or reset by all
member functions affecting elements in the class. Member functions are provided
to reset the current position, move to the next and previous elements, find an
element, and get the value at the current position. The
Iterator< Type >
class
provides a mechanism to save and restore the state associated with the current
position, thus allowing the programmer to use multiple iterators over the same
instance of a tree.
.PP
Traversal through an n-ary tree using the current position mechanism and the
Iterator< Type >
class can be controlled by setting the traversal mode. An
enumerated type
Traversal_Type
is defined for the following values:
.PP
.TP .2i
\(bu
PREORDER
.TP
\(bu
PREORDER_REVERSE
.TP
\(bu
INORDER
.TP
\(bu
INORDER_REVERSE
.TP
\(bu
POSTORDER
.TP
\(bu
POSTORDER_REVERSE
.PP
Inorder traversal for an n-ary tree is defined to traverse the left-most
subtree, visit the node, then traverse all remaining subtrees from left to
right. Postorder traversal of an n-ary tree is defined to traverse all subtrees
from left to right, then visit the node. Preorder traversal for an n-ary tree
is defined to visit the node, then traverse all subtrees from left to right.
The reverse traversal modes are similar, except that they visit subtrees from